﻿@section header{

}
<form id="form1">
    <div class="form-layout">
        <input type="hidden" name="userids" id="userids" />
        <table class="form">
            <tr>
                <th class="formTitle">角色列表</th>
            </tr>
            <tr>
                <td class="formValue">
                    <ul style="width: 95%;">
                        @foreach(Role item in Model) {
                            <li style="float: left;width: 30%;display: inline">
                                <input id="@item.ID" name="roleIds" type="checkbox" value="@item.ID" />@item.Name
                            </li>
                        }
                    </ul>
                </td>
            </tr>

        </table>
    </div>
</form>
@section scripts{
    <script>
        var pageUrl = "/rbac/User/";
        var keyValue = $.request("keyValue");
        $(function () {
            initControl();
            if (!!keyValue) {
                $("#userids").val(keyValue);
            }
        });
        function initControl() {

        }
        function submitForm() {
            if (!$('#form1').formValid()) {
                return false;
            }
            var obj = document.getElementsByName("roleIds");
            check_val = [];
            for (k in obj) {
                if (obj[k].checked)
                    check_val.push(obj[k].value);
            }


            var aurl = pageUrl + "UserRole";
            var formval = $("#form1").formSerialize();
            formval["roleIds"] = check_val;
           
            console.log(formval);
            $.submitForm({
                url: aurl,
                param: formval,
                success: function () {
                    $.currentWindow().$("#gridList").resetSelection();
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        }
    </script>
}